package com.lovo.controller;

import com.lovo.bean.CutPageBean;
import com.lovo.bean.PostBean;
import com.lovo.sercive.IPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@RequestMapping("post")
public class PostController {

    @Autowired
    private IPostService service;

    @RequestMapping("findByItem")
    public CutPageBean<PostBean> findByItem(int pageNO, int channelId, String title, String writer, LocalDate startDate, LocalDate endDate) {
        CutPageBean<PostBean> cut = service.findByItem(pageNO, channelId, title, writer, startDate, endDate);
        return cut;
    }

    @RequestMapping("add")
    public String addPost(PostBean post) {
        service.addPost(post);
        return "ok";
    }

    @RequestMapping("findById")
    public PostBean findById(Integer id) {
        return service.findById(id);
    }
}
